#include"process.h"
#include<string.h>
#include<unistd.h>

typedef void (*callback_t)(double total, double current);

double total = 1024.0;
double speed = 1.0;

void DownLoad(callback_t cb)
{
    double current = 0.0;
    while(current <= total)
    {
        cb(total,current);
        usleep(3000); // 充当下载数据
        current += speed;
    }
    printf("\nDownLoad %.2lfMB Done\n",current);
}

void UpLoad(callback_t cb)
{
    double current = 0.0;                                                                                                                                                     
    while(current <= total)
    {
        cb(total,current);
        usleep(3000); // 充当下载数据
        current += speed;
   } 
    printf("\nDownLoad %.2lfMB Done\n",current);
}


int main()
{
    //process_v1();
    DownLoad(FlushProcess);
    UpLoad(FlushProcess);
    UpLoad(FlushProcess);
    UpLoad(FlushProcess);
    UpLoad(FlushProcess);
    UpLoad(FlushProcess);
    UpLoad(FlushProcess);
    UpLoad(FlushProcess);
    UpLoad(FlushProcess);

    return 0;
}
